package 数据结构和算法.算法.递归.冒泡排序;

import java.util.Arrays;

public class BubblleSort {
    public static void main(String[] args) {
        int[] arrays = {2, 5, 1, 4, 3, 9, 7, 8, 3};
        bubbleSort(arrays, 0, arrays.length - 1);
        System.out.println(Arrays.toString(arrays));
    }

    public static void bubbleSort(int[] arrays, int L, int R) {
        int temp;
        if (L == R) {
        } else {
            for (int i = L; i < R; ++i) {
                if (arrays[i] > arrays[i + 1]) {
                    temp = arrays[i];
                    arrays[i] = arrays[i + 1];
                    arrays[i + 1] = temp;
                }
            }
            bubbleSort(arrays, L, R - 1);
        }
    }
}
